#define N 5
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
struct student
{
  char num[100];
  double score;
};
int main()
{
  struct student s[N], t[N];
  int i;
  FILE *fp;
  fp = fopen("student.dat", "w");
  if (fp == NULL)
  {
    cout << "can't open student.dat" << endl;
    exit(1);
  }
  for (i = 0; i < N; i++)
  {
    cin >> s[i].num >> s[i].score;
    fwrite(&s[i], sizeof(student), 1, fp);
  }
  fclose(fp);
  if ((fp = fopen("student.dat", "r")) == NULL)
  {
    cout << "can't open student.dat" << endl;
    exit(1);
  }
  fread(t, sizeof(t), 1, fp);
  for (i = 0; i < N; i++)
    cout << t[i].num << t[i].score << endl;
  fclose(fp);
  system("pause");
  return 0;
}